﻿@using GoodMan.Infrastructure.Entities.Entity;
@{
    ViewBag.Title = "返佣报表";
    Layout = "~/Areas/WorkSpace/Views/Shared/_OfficerTemplete.cshtml";
    ItemListBox<RebateReport> data = ViewBag.data;
    string startYear=ViewBag.startYear;
    string startMonth = ViewBag.startMonth;
    string endYear = ViewBag.endYear;
    string endMonth = ViewBag.endMonth;
}
@section head{
 <script type="text/javascript" src="/Scripts/jquery.js"></script>
    <script type="text/javascript" src="/Scripts/plug.js"></script>
     <link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
    <script type="text/javascript">
        var control = new plug.Control();
        var datasource = @Html.Raw(ViewBag.MonthList);
        $(function () {
               control.BuildRelationSelect({element:'startYear',defaultvalue:@startYear}, {element:'startMonth',defaultvalue:@startMonth}, datasource);
               control.BuildRelationSelect({element:'endYear',defaultvalue:@endYear}, {element:'endMonth',defaultvalue:@endMonth}, datasource);
            
        });
    </script>
}
<div id="content-header">
    <h1>
        返佣报表</h1>
</div>
<div id="breadcrumb">
    <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>
        首页</a> <a href="#" class="tip-bottom">返佣管理</a> <a href="#" class="current">返佣报表</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-th"></i></span>
                    <h5>
                        返佣报表</h5>
                </div>
                
                <div class="widget-content nopadding">
               
                <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td style="width:100%">
                                <div class="control-group">
                                     <form action="/Officer/SearchRebateReport" method="post" class="form-horizontal">
                                    <div class="controls">
                                       返佣月份：<select id="startYear" name="startYear" style="width:100px">
                                        </select>年
                                        <select id="startMonth" name="startMonth" style="width:100px">
                                        </select>月 至
                                        <select id="endYear" name="endYear" style="width:100px">
                                        </select> 年
                                        <select id="endMonth" name="endMonth" style="width:100px">
                                        </select> 月
                                        <button type="submit" class="btn btn-primary">
                                        <i class="icon-search icon-white"></i>查询</button>
                                    </div>
                                    </form>
                                </div>
                            </td>
                            </tr>
                            <tr>
                            <td>
                    <table class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th width="8%">
                                    年月
                                </th>
                                <th width="5%">
                                    楼栋
                                </th>
                                <th width="10%">
                                    姓名
                                </th>
                                 <th width="10%">
                                    处理订单量
                                </th>
                                <th width="10%">
                                    成功订单量
                                </th>
                                <th width="10%">
                                    取消订单量
                                </th>
                                <th width="10%">
                                    成功订单金额
                                </th>
                                 <th width="10%">
                                    返点%
                                </th>
                                <th width="8%">
                                    返点金额
                                </th>
                                 <th width="8%">
                                    调整
                                </th>
                                <th width="8%">
                                    佣金
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                        @{
                            if (data != null &&data.Data!=null&& data.Data.Any())
                            {

                                foreach (var rebate in data.Data)
                                 {
                                    int dealorders = rebate.SuccessOrders + rebate.CancelOrders;
                                    decimal bonusmoney = Math.Round(rebate.SuccessMoney * rebate.Rebate / 100, 2);
                                    decimal lastmoney = bonusmoney + rebate.Bonus;

                                    <tr>
                                    <td>
                                        @rebate.Year -  @rebate.Month
                                    </td>
                                    <td>
                                        @rebate.dormitory.Name
                                    </td>
                                    <td>
                                        @rebate.user.RealName
                                    </td>
                                    <td class="center">
                                        @dealorders 
                                    </td>
                                    <td class="center">
                                        @rebate.SuccessOrders
                                    </td>
                                    <td class="center">
                                        @rebate.CancelOrders
                                    </td>
                                    <td class="center">
                                        @rebate.SuccessMoney
                                    </td>
                                        <td class="center">
                                         @(rebate.Rebate)%
                                    </td>
                                    <td class="center">
                                        @bonusmoney
                                    </td>
                                    <td class="center">
                                        @rebate.Bonus
                                    </td>
                                    <td class="center">
                                        @lastmoney
                                    </td>
                                    </tr>
                                }
                                
                            }
                             else
                             {
                                  <tr>
                                    <td colspan="11" align="center">
                                        无报表数据
                                    </td>
                                </tr>  
                             }
                        }
                        </tbody>
                        <tfoot>
                        <tr><td  colspan="11" > </div>
                @Html.Raw(data.PageItemSegment)
            </div></td></tr>
                        </tfoot>
                    </table>
                    </td></tr>
                    </table>

                    
                </div>
                      
            </div>
             
        </div>
    </div>
</div>
@section tail{
<script type="text/javascript">
    $(function () {
        $('#likRebate').addClass('open');
        $('#likRebate').addClass('active');
 
        $('#startYear').each(function () {
            $(this).select2();
        });
        $('#startMonth').each(function () {
            $(this).select2();
        });
        $('#endYear').each(function () {
            $(this).select2();
        });
        $('#endMonth').each(function () {
            $(this).select2();
        });
    });
</script>
